    joinChat(tempName);

    var chatColor = ['', '#84B391', '#6ea1cd', '#cf7569', '#c9ba66', '#EB8D68', '#b480ba'],
            chatBox = ['', 'reply-form-choose-color-red', 'reply-form-choose-color-blue', 'reply-form-choose-color-orange', 'reply-form-choose-color-green', 'reply-form-choose-color-grey', 'reply-form-choose-color-purple'],
            i = 1,
            j = 0,
            chatExists = [false, 0],
            color = "",
            chatToWriteTo = "",
            msg = "";

    inChat = true;

    function serverMsg (msgText, color) {
        if (typeof color !== 'undefined') {
            return '<span class="10" style="display: block"><div class="message-container" style="background-color: ' + color + '"><div class="message-author"><a href="profile.html?name=SERVER" target="_blank">SERVER</a></div><div class="message-image" style="background-image:url(bilder/server.png);"><div class="message-account"></div></div><div class="message-overlay">I watch you when you sleep</div>' + msgText + '</div></span>';
        } else {
            return '<span class="10" style="display: block"><div class="message-container"><div class="message-author"><a href="profile.html?name=SERVER" target="_blank">SERVER</a></div><div class="message-image" style="background-image:url(bilder/server1.png);"><div class="message-account"></div></div><div class="message-overlay">I watch you when you sleep.</div>' + msgText + '</div></span>';
        }
    }

    function regularMsg (ID, msgDisplay, msgColor, user, msgText, msgID, icon) {
        if (icon === "undefined") {
            icon = "duck";
        }
        msgText = msgConverter(msgText);
        msg = '<span class="1' + ID + '" style="display: ' + msgDisplay + '">\n\
                <div id="' + msgID + '" class="message-container" style="background-color: ' + msgColor + '">\n\
                <div id="replyDiv' + msgID + '" class="message-reply-div" style="display:none"></div>\n\
                <div class="message-id-container">#' + msgID + '</div>\n\
                <div class="message-reply-indicator" style="display:none" id="replyIndicator' + msgID + '"  onmouseover="showReply(' + msgID + ');" onmouseout="hideReply(' + msgID + ');"></div>\n\
                <div class="message-author"><a href="profile.html?name=' + user + '" target="_blank">' + user + '</a></div>\n\
                <div class="message-timestamp"></div>\n\
                <div class="message-image" style="background-image:url(bilder/icons/' + icon + '.png);">\n\
                <div class="message-account" style="color: ' + msgColor + '"></div></div>\n\
                <div class="message-overlay"><div class="message-overlay-vote-up">+</div>\n\
                <div class="message-overlay-vote-down">-</div></div><div class="chatMsg">' + msgText + '</div></div></span>';
        return msg;
    }

    function privateMsg (user, msgText, color) {
        msgText = msgConverter(msgText);
        msg = '<span class="11" style="display: block"><div class="message-container" style="background-color: ' + color + '"><div class="message-author"><a href="profile.html?name=' + user + '" target="_blank">' + user + '</a></div><div class="message-timestamp"></div><div class="message-image" style="background-image:url(bilder/premiumbonsai.png);"><div class="message-account"></div></div><div class="message-overlay">This is a private message.</div><span class="chatMsg">' + msgText + '</span></div></span>';
        return msg;
    }


    var placeholder = 'Select the color below for the chatroom you want to write in.\nWant to send a private message? Use @ + Account name then the message. Ex. @user Hello There!';
    $('textarea').val(placeholder);

    $('textarea').focus(function () {
        if ($(this).val() === placeholder) {
            $(this).val('');
        }
    });

    $('textarea').blur(function () {
        if ($(this).val() === '') {
            $(this).val(placeholder);
        }
    });

    $('.chat_room-header-arrow-down').click(function () {
        $('#chat_room-large-header-test').toggle();
       
        j++;
        
        document.getElementById('arrow').style.transform='rotate('+j*180+'deg)';
        
    });

    function leaveChat (chat_name) { //Leave chat, söker igenom chatrooms arrayen efter chat-namnet och tar bort hela arrayen i arrayen (array-ception).

        for (var x = 0; x < chatrooms.length; x += 1) {
            if (chatrooms[x].indexOf(chat_name) > -1) {
                chatExists = [true, x];
            }
        }

        if (chatExists[0] === true) {
            $('#' + chat_name).remove();
            chatrooms.splice(chatExists[1], 1);
            $('.topic-box-test#' + chat_name).remove();
            if ($('.' + chat_name).css('color') === "rgb(255, 0, 0)") {
                chatToWriteTo = "";
            }
            $('.' + chat_name).remove();
            socket.emit('leaveChat', {chatRoom: chat_name});
            i -= 1;
        } else {
            $('.topic-box-test#' + chat_name).remove();
            if ($('.' + chat_name).css('color') === "rgb(255, 0, 0)") {
                chatToWriteTo = "";
            }
            $('.' + chat_name).remove();
            $('#chat_room-test').append(serverMsg('You are not connected to ' + chat_name));
            $('#chat_room-test').scrollTop($('#chat_room-test').prop("scrollHeight"));
            socket.emit('leaveChat', {chatRoom: chat_name});
        }

        $('#chat_room-large-header-your-topics > div').each(function () {
            color = chatColor[$('.topic-box-test#' + $(this).attr('id')).index() + 1];
            $('.topic-box-test#' + $(this).attr('id')).css('background-color', color);
            $('.' + $(this).attr('id')).css('background-color', color);
            $('.topic-box-test').data($('.topic-box-test').data($(this).attr('id')) + "", color);
        });

    }

    function allowDrop (ev) {
        ev.preventDefault();
    }

    function drag (ev) {
        ev.dataTransfer.setData("Text", ev.target.id);
    }

    function drop (ev) {
        ev.preventDefault();
        var data = ev.dataTransfer.getData("Text");
        ev.target.appendChild(document.getElementById(data));
        leaveChat(data);
    }

    function replyButtonPress (element) {
        if ($('textarea').val() === placeholder) {
            $('textarea').val('#' + element.parents('.message-container').attr('id') + ' ');
        } else {
            $('textarea').val('#' + element.parents('.message-container').attr('id') + ' ' + $('textarea').val());
        }
    }

    //What do you call a mexican who lost his car? Carloss
    //What did the mexican firefighter call his 2 kids? HoseA and HoseB

    socket.on('addID', function (id, name, au) { //Servern emittar 'addID' när klienten joinat en chat, lägger till värdena till chatten i chatrooms-arrayen.
        if ($('.topic-box-test#' + name).length === 0) { //om chatrummet INTE finns i högra spalten i chatrummet:
            $('#chat_room-large-header-your-topics').append('<div class="topic-box-test" id="' + name + '" draggable="true" ondragstart="drag(event)"><div class="topic-box-topic-test">#' + name + '</div></div>');

            chatrooms[i - 1] = [];
            chatrooms[i - 1].push(name, au, id, chatColor[i]);

            if ($('#chat_room-choose-color > div').length === 0) {
                $('#chat_room-choose-color').append('<div class="reply-form-choose-color ' + name + '" style="color: red; border: 4px solid #333; background-image: url(https://cdn2.iconfinder.com/data/icons/flat-ui-icons-24-px/24/checkmark-24-32.png); background-repeat: no-repeat; background-position: center;"></div>');
                for (var p = 0; p < chatrooms.length; p += 1) {
                    if (chatrooms[p].indexOf(name) !== -1) {
                        chatToWriteTo = chatrooms[p];
                    }
                }
            } else {
                $('#chat_room-choose-color').append('<div class="reply-form-choose-color ' + name + '"></div>');
            }

            color = chatColor[$('.topic-box-test#' + name).index() + 1];
            $('.topic-box-test#' + name).css('background-color', color);
            $('.' + name).css('background-color', color);
            $('.topic-box-test').data(id + "", color);
            $('.topic-box-test').data(name, id);

        } else {
            console.log('wtf');
        }
        i += 1;
    });

    socket.on('updateRoom', function (username, msg, chatID, msgID, replyID, icon) { //Servern emittar 'updateRoom' när ett nytt meddelande har skrivits
        if (chatID === 0) { //chatID === 0 är ett [SERVER] meddelande, t.ex. "user has joined chat".
            color = chatColor[0];
            $('#chat_room-test').append(serverMsg(msg));

            if ($('#chat_room-test:hover').length === 0) { //pausar nerscrollning om muspekaren är i chatten
                $('#chat_room-test').scrollTop($('#chat_room-test').prop("scrollHeight"));//Scrolla längst ner i chatten 
            }
        } else if (chatID === "pm") {
            color = chatColor[7];
            $('#private').append(privateMsg(username, msg, chatColor[7]));

            if ($('#chat_room-test:hover').length === 0) { //pausar nerscrollning om muspekaren är i chatten
                $('#chat_room-test').scrollTop($('#chat_room-test').prop("scrollHeight"));//Scrolla längst ner i chatten 
            }
        } else {
            var arrayLength = chatrooms.length;
            for (var f = 0; f < arrayLength; f++) {
                if (chatrooms[f][2] === chatID) {
                    if ($('.topic-box-test#' + chatrooms[f][0]).css('background-color') === "rgb(229, 229, 229)") { //om urklickad
                        var display = 'none';
                    } else {
                        var display = 'block';
                        $('.1' + chatID).css('display', display);
                    }
                    color = $('.topic-box-test').data(chatID + "");
                    if (username === 'SERVER') {
                        $('#chat_room-test').append(serverMsg(msg, color));
                    } else {
                        if (replyID) {
                            if ($('#' + replyID).length > 0) {
                                //$('#' + replyID).parent('#replyImg').style.display="block";
                                //  $('#' + replyID).parent('#replyDiv').innerHTML=regularMsg(chatID, display, color, username, msg, msgID);

                                $('#chat_room-test').append(regularMsg(chatID, display, color, username, msg, msgID, icon));
                                $('#replyIndicator' + msgID).css("display", "block");
                                $('#' + replyID).parent().html();
                                $('#replyDiv' + msgID).html($('#' + replyID).parent().html());

                            } else {
                                $('#chat_room-test').append(regularMsg(chatID, display, color, username, msg, msgID, icon));
                            }
                        } else {
                            $('#chat_room-test').append(regularMsg(chatID, display, color, username, msg, msgID, icon));
                        }
                    }
                    $('.' + chatID).css("color", color); // Om man lämnar en chat och sedan joinar den igen så gör den så att alla meddelandena har samma färg. Vet ej om den här fungerar.
                    if ($('#chat_room-test:hover').length === 0) {
                        $('#chat_room-test').scrollTop($('#chat_room-test').prop("scrollHeight"));//Scrolla längst ner i chatten (om musen inte är där!)
                    }
                    break;
                }
            }
        }
    });

    socket.on('redirect', function (data) {
        $("#chat_room-test").append(serverMsg(data, chatColor[0]));
    });

    socket.on('deleteRoom', function (data) {
        leaveChat(data);

    });

    socket.on('updateActive', function (data) {
        if (chatToWriteTo[2] == data.id) {
            $("#chat_room-test").append(serverMsg("Active users in this chat: " + data.activeUsers, chatColor[0]));
        }
    });

    socket.on('mostUpVoted', function (data) { // object.votes/msg/author/msgID
        //ID, msgDisplay, msgColor, user, msgText, msgID
        //data.topUpVoted är en array, [*][0] är antal votes, [*][1][0] användarnamn, [*][1][1] msgID, [*][1][2] msg
        //ID, msgDisplay, msgColor, user, msgText, msgID
        $("#mostUpVoted").html("");
        data.forEach(function (data) {
            $("#mostUpVoted").append(regularMsg(data.chatID, "block", chatToWriteTo[3], data.author, "hej", data._id, "duck"));
            $('#' + data._id).children(".message-timestamp").html('+' + data.votes);
        });

        //for (var i = 0; i < data.topUpVoted.length; i++) {
        //  msg = msg + regularMsg(0, 'block', $('.topic-box-test').data(data.chatid + ""), data.topUpVoted[i][1][0], data.topUpVoted[i][1][2], data.topUpVoted[i][1][1]);
        // $('#mostUpVoted').append(regularMsg(0, 'block', '#333', data.topUpVoted[i][1][0], data.topUpVoted[i][1][2], data.topUpVoted[i][1][1]));
        //}
        //document.getElementById('mostUpVoted').innerHTML = msg;

    });

    function getMostUpvoted () {
        socket.emit("getMostUpvoted", {chatID: chatToWriteTo[2]});
    }

    socket.on('updateUpVotes', function (data) {
        if ($('#' + data.msgID).length !== 0) {
            if (data.votes === 0) {
            } else if (data.votes > 0) {
                $('#' + data.msgID).children(".message-timestamp").html('+' + data.votes); //not working after 1
            } else if (data.votes < 0) {
                $('#' + data.msgID).children('.message-timestamp').html(data.votes);
            }
        }
    });

    $(document).on('click', '.message-overlay-vote-up', function () {
        var chatMsgUp = $(this).parents(".message-container").children('.chatMsg').html();
        socket.emit('upVote', {user: $(this).parents(".message-container").children('.message-author').children('a').text(), msg: chatMsgUp, chatID: $(this).parents("span").attr('class').substr(1), msgID: $(this).parents(".message-container").attr('id')});
    });

    $(document).on('click', '.message-overlay-vote-down', function () {
        var chatMsgUp = $(this).parents(".message-container").children('.chatMsg').html();
        socket.emit('downVote', {user: $(this).parents(".message-container").children('.message-author').children('a').text(), msg: chatMsgUp, chatName: $(this).parents("span").attr('class').substr(1), msgID: $(this).parents(".message-container").attr('id')});
    });

    $(document).on('click', '.message-overlay-reply', function () {
        replyButtonPress($(this));
    });

    $('#chat_room-choose-color').on('click', '> *', function () {

        if ($(this).css('color') === 'rgb(255, 0, 0)') {
            emptyCss($(this));
            chatToWriteTo = '';
        } else {
            $('#chat_room-choose-color').children('div').each(function () {
                if ($(this).css('color') === 'rgb(255, 0, 0)') {
                    emptyCss($(this));
                }
            });
            chatToWriteTo = '';
            $(this).css('color', 'red');
            $(this).css('border', '4px solid #333');
            $(this).css('background-image', 'url(https://cdn2.iconfinder.com/data/icons/flat-ui-icons-24-px/24/checkmark-24-32.png)');
            $(this).css('background-repeat', 'no-repeat');
            $(this).css('background-position', 'center');
            for (var p = 0; p < chatrooms.length; p += 1) {
                if (chatrooms[p].indexOf($(this).attr('class').substr(24)) !== -1) {
                    chatToWriteTo = chatrooms[p];
                }
            }
        }

        function emptyCss (element) {
            element.css('color', 'rgb(0, 0, 0)');
            element.css('border', '');
            element.css('background-image', '');
            element.css('background-repeat', '');
            element.css('background-position', '');
        }

    });

    function submitMsg (msg1) {
        if (msg1.indexOf('!') === 0) { //Om meddelandet börjar med ! så antas det vara ett kommando och det skickas inte till servern
            var shortCmd = msg1.slice(1, msg1.indexOf(' ')), //kommandot
                    CmdVal = msg1.slice(msg1.indexOf(' ') + 1); //värdet efter kommandot, hejsan i !join hejsan

            switch (shortCmd) {
                case 'discover':
                    socket.emit('discover', {list: CmdVal});
                    break;
                case "ban":
                    socket.emit("ban", {user: CmdVal, token: getCookie("token"), chatID: chatToWriteTo[2], room: chatToWriteTo[0]});
                    break;
               case "unban":
                    socket.emit("unban", {user: CmdVal, token: getCookie("token"), chatID: chatToWriteTo[2], room: chatToWriteTo[0]});
                    break;
                case 'kick':
                    socket.emit('kick', {user: CmdVal, token: getCookie('token'), chatID: chatToWriteTo[2], room: chatToWriteTo[0]});
                    break;
                case 'read':
                    if (/^[0-9a-zA-Z]+$/.test(CmdVal)) {
                        socket.emit('readlist', {user: CmdVal, token: getCookie('token'), id: chatToWriteTo[2], name: chatToWriteTo[0]});
                    } else {
                        $('#chat_room-test').append(serverMsg('Only letters and numbers are accepted.'));
                    }
                    break;
                case 'write':
                    if (/^[0-9a-zA-Z]+$/.test(CmdVal)) {
                        socket.emit('writelist', {user: CmdVal, token: getCookie('token'), id: chatToWriteTo[2]});
                    } else {
                        $('#chat_room-test').append(serverMsg('Only letters and numbers are accepted.'));
                    }
                    break;
                case "favourite":
                    if(/^[0-9a-zA-Z]+$/.test(CmdVal)) {
                        socket.emit("favourite", CmdVal);
                    } else {
                        $("#chat_room-test").append(serverMsg("Only letters and numbers are accepted."));
                    }
                    break;
                case "unfavourite":
                    if(/^[0-9a-zA-Z]+$/.test(CmdVal)) {
                        socket.emit("unfavourite", CmdVal);
                    } else {
                        $("#chat_room-test").append(serverMsg("Only letters and numbers are accepted."));
                    }
                    break;
                case 'join':
                    if (/^[0-9a-zA-Z]+$/.test(CmdVal)) {
                        joinChat(CmdVal);
                    } else {
                        $('#chat_room-test').append(serverMsg('Only letters and numbers are accepted.'));
                    }
                    break;
                case 'leave':
                    if (/^[0-9a-zA-Z]+$/.test(CmdVal)) {
                        for (var i = 0; i < chatrooms.length; i += 1) {
                            if (chatrooms[i].indexOf(CmdVal) !== -1) {
                                leaveChat(CmdVal);
                            }
                        }
                    } else {
                        $('#chat_room-test').append(serverMsg('Only letters and numbers are accepted.'));
                    }
                    break;
                case 'speed':
                        if (chatToWriteTo === "") {
                            $('#chat_room-test').append(serverMsg('Select a chat to set its speed.'));
                        } else {
                            socket.emit('setSpeed', {speed: (CmdVal - 0), token: getCookie('token'), room: chatToWriteTo[0], id: chatToWriteTo[2]});
                        }
                    break;
            }
        } else if (chatToWriteTo === "") {
            $('#chat_room-test').append(serverMsg('Select a chat to write to.'));
        } else if ($('textarea').val() === placeholder) {
            $('#chat_room-test').append(serverMsg("You are not very creative."));
        } else { //Om det är ett vanligt meddelande:
            socket.emit('sendMsg', {chatRoom: chatToWriteTo, msg: msg1});
        }
    }

    $('#chat_form').submit(function (event) { // Eventet sker när man submitat ett nytt meddelande
        submitMsg($('#message').val());
        $('#message').val(placeholder); //Nollställ textrutan för meddelanden
        event.preventDefault();
    });

    $('#message').keydown(function (e) {
        e = e || event;

        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
            submitMsg($('#message').val());
            $('#message').val(''); //Nollställ textrutan för meddelanden
        }
    });

    $('#chat_room-large-header-your-topics').on('click', '.topic-box-test', function () { //lägg till event för när man klickar på ett chatrum i högra spalten på chatten
        if ($(this).css('background-color') === "rgb(229, 229, 229)") { //Om background-color på chat-rutan är e5e5e5 (gråa färgen)
            $(this).css('background-color', $(this).data('oldbgcolor'));
        } else { //om färgen inte är grå så blir den grå
            $(this).data('oldbgcolor', $(this).css('background-color'));
            $(this).css('background-color', '#e5e5e5');
        }
    });

    function msgConverter (msg) {
        msg = msg.replace(/ApeFace/g, '<img class="smily" src="/bilder/apeface2.png")">');
        msg = msg.replace(/\:\)/g, '<img src="bilder/emoticonbrick).png">');
        msg = msg.replace(/\:\(/g, '<img src="bilder/emoticonbrick(.png">');
        msg = msg.replace(/\:D/g, '<img src="bilder/emoticonbrickD.png">');
        msg = msg.replace(/D\:/g, '<img src="bilder/emoticonbrickDrevert.png">');
        msg = msg.replace(/\:P/g, '<img src="bilder/emoticonbrickP.png">');
        msg = msg.replace(/oO/g, '<img src="bilder/emoticonbrickconfused.png">');
        msg = msg.replace(/Creep/g, '<img src="bilder/emoticonbrickcreep.png">');
        msg = msg.replace(/\;\)/g, '<img src="bilder/emoticonbrickflirt.png">');
        msg = msg.replace(/\:O/g, '<img src="bilder/emoticonbrickgasp.png">');
        msg = msg.replace(/ \:\//g, '<img src="bilder/emoticonbrickslash.png">');
        msg = msg.replace(/\:\'\(/g, '<img src="bilder/emoticonbricktear.png">');
        msg = msg.replace(/\-\_\-/g, '<img src="bilder/emoticonbrick-_-.png">');
        msg = msg.replace(/Chloe/g, '<img class="smily" src="bilder/chloesmiley2.png">');
        msg = msg.replace(/Yoda/g, '<img src="bilder/yoda.png">');
        msg = msg.replace(/HugeQ/g, '<img class="smily" src="bilder/hugeQsmall.png">');
        msg = msg.replace(/\<3/g, '<img src="bilder/heart.png">');
        msg = msg.replace(/\>\</g, '<img src="bilder/grumpy.png">');
        msg = msg.replace(/EgyptZ/g, '<img src="bilder/littleegypt.png">');
        msg = msg.replace(/Egyptz/g, '<img src="bilder/littleegypt2.png">');
        msg = msg.replace(/Loop/g, '<img src="bilder/littleegyptloop2.gif">');
        msg = msg.replace(/Pool/g, '<img src="bilder/littleegyptloop.gif">');
        msg = msg.replace(/\:\]/g, '<img src="bilder/robot.png">');
        msg = msg.replace(/Cho/g, '<img src="bilder/locomotive.png">');
        msg = msg.replace(/Train/g, '<img src="bilder/locomotive_1.gif">');
        msg = msg.replace(/Crappa/g, '<img class="smily" src="bilder/Cristobal2.png">');
        msg = msg.replace(/Carriage/g, '<img src="bilder/carriage.png">');
        msg = msg.replace(/Ygg/g, '<img class="smily" src="bilder/ygge2.png">');
        msg = msg.replace(/Svamp/g, '<img src="bilder/svamp2.png">');
        msg = msg.replace(/Uggla/g, '<img class="smily" src="bilder/owl.png">');
        msg = msg.replace(/Snubbe/g, '<img class="smily" src="bilder/dude.png">');
        msg = msg.replace(/ConfessionBear/g, '<img class="smily" src="bilder/CBear.png">');
        msg = msg.replace(/Rein/g, '<img class="smily" src="bilder/reinfeldt.png">');
        msg = msg.replace(/Gudrun/g, '<img class="smily" src="bilder/gudrun.png">');
        msg = msg.replace(/Bjork/g, '<img class="smily" src="bilder/bjorklund.png">');
        msg = msg.replace(/Ake/g, '<img class="smily" src="bilder/akesson.png">');
        msg = msg.replace(/InsanityWolf/g,'<img class="smily" src="bilder/InsanityWolf.png">');
        //msg=Autolinker.link(msg);
        return msg;
    }

    $('#chat_room-large-header-your-topics').on('click', '.topic-box-test', function () { //lägg till event för när man klickar på ett chatrum i högra spalten på chatten
        if ($(this).css('background-color') === "rgb(229, 229, 229)") { //Om background-color på chat-rutan är e5e5e5 (gråa färgen)
            $(this).css('background-color', $(this).data('oldbgcolor'));
        } else { //om färgen inte är grå så blir den grå
            $(this).data('oldbgcolor', $(this).css('background-color'));
            $(this).css('background-color', '#e5e5e5');
        }
    });


    function showCommands () {
        document.getElementById('commandBox').style.display = "block";
    }
    function hideCommands () {
        document.getElementById('commandBox').style.display = "none";
    }
    function swapView (view) { // different tabs in chat room, pm's latest tree mostupvoted
       
        document.getElementById('chat_form').style.display = "none";
        document.getElementById('chat_room-test').style.display = "none";
        document.getElementById('mostUpVoted').style.display = "none";
        document.getElementById('browse').style.display = "none";
        document.getElementById('private').style.display = "none";
        document.getElementById(view).style.display = "inline";
        document.getElementById('latestButton').style.color = "#e7e7e7";
        document.getElementById('mostUpVotedButton').style.color = "#e7e7e7";
        document.getElementById('browseButton').style.color = "#e7e7e7";
        document.getElementById('privateButton').style.color = "#e7e7e7";
        if (view === 'chat_room-test') {
            document.getElementById('latestButton').style.color = "#D34836";
            document.getElementById('chat_form').style.display = "block";
        } else if (view === "private") {
            document.getElementById('privateButton').style.color = "#D34836";
            document.getElementById('chat_form').style.display = "block";
        } else if (view === "mostUpVoted") {
            document.getElementById('mostUpVotedButton').style.color = "#D34836";
            getMostUpvoted();
        }
        else {
            document.getElementById(view + 'Button').style.color = "#D34836";
        }
    }

    function showReply (msgID) {
        
        $('#replyDiv' + msgID).css("display", "block");
    }
    function hideReply (msgID) {
        $('#replyDiv' + msgID).css("display", "none");
    }
    
